import 'package:get/get.dart';
import 'package:situation/app/router/router_name.dart';
import 'package:situation/data/request/intell_request.dart';
import 'package:situation/domain/intell/intell_history_dto.dart';

import 'state.dart';

class IntelHistoryController extends GetxController {
  final IntelHistoryState state = IntelHistoryState();

  @override
  void onInit(){
    super.onInit();

    onRefresh();
  }


  Future<void> onRefresh() async {
    List<IntellHistoryDto> intellHistory = await IntellRequest.getMyIntell();
    state.intellHistory = intellHistory;
  }

  void toDetail(int index) {
    Get.toNamed(RouterName.intellDetail, arguments: {
      'id': state.intellHistory[index].id,
    });
  }
}
